package com.cgwx.tcservice.client;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cgwx.commonutils.result.SysResult;
import com.cgwx.springsecurity.entity.SysLoginLog;
import com.cgwx.springsecurity.entity.SysLoginLogQueryVo;
import com.cgwx.springsecurity.entity.SysOperLog;
import com.cgwx.springsecurity.entity.SysOperLogQueryVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

/**
 * @author GaoWei
 * @Date 2023/10/28 - 11:27
 */

@Component
@FeignClient(name = "service-system",fallback = SystemHystrixFeignClient.class)
public interface SystemClient {

    @PostMapping("/system/sysOperLog/saveSysLog")
    SysResult saveSysLog(
            @ApiParam(name = "operLog", value = "待保存的操作日志")
            @RequestBody SysOperLog operLog);

    @GetMapping("/system/sysOperLog/selectPage/{page}/{limit}")
    IPage<SysOperLog> selectOperPage(
            @ApiParam(name = "page", value = "当前页码", required = true)
            @PathVariable("page") Long page,

            @ApiParam(name = "limit", value = "每页记录数", required = true)
            @PathVariable("limit") Long limit,

            @ApiParam(name = "sysOperLogQueryVo", value = "查询对象")
            @RequestBody SysOperLogQueryVo sysOperLogQueryVo);

    @PostMapping("/system/userDetails/saveSysLog/{username}")
    UserDetails loadUserByUsername(
            @ApiParam(name = "username", value = "用户名")
            @PathVariable("username") String username);

    @PostMapping("/system/sysLoginLog/recordLoginLog/{username}/{status}/{ipaddr}/{message}")
    SysResult recordLoginLog(
            @ApiParam(name = "username", value = "用户名")
            @PathVariable("username") String username,

            @ApiParam(name = "status", value = "用户状态")
            @PathVariable("status") Integer status,

            @ApiParam(name = "ipaddr", value = "IP地址")
            @PathVariable("ipaddr") String ipaddr,

            @ApiParam(name = "message", value = "用户信息")
            @PathVariable("message") String message);

    @GetMapping("/system/sysLoginLog/selectPage/{page}/{limit}")
    IPage<SysLoginLog> selectLoginPage(
            @ApiParam(name = "page", value = "当前页码", required = true)
            @PathVariable("page") Long page,

            @ApiParam(name = "limit", value = "每页记录数", required = true)
            @PathVariable("limit") Long limit,

            @ApiParam(name = "sysLoginLogQueryVo", value = "查询对象")
            @RequestBody SysLoginLogQueryVo sysLoginLogQueryVo);
}
